package com.huike.service.Transfer.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.page.PageMethod;
import com.huike.mapper.assignRecor.AssignRecordMapper;
import com.huike.pojo.SysUser;
import com.huike.service.Transfer.TransferService;
import com.huike.service.User.UserService;
import com.huike.vo.TransferVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TransferServiceImpl implements TransferService {

    @Autowired
    private UserService userService;

    @Autowired
    private AssignRecordMapper assignRecordMapper;

    @Override
    public List<TransferVo> selectList(SysUser user) {
        ArrayList<TransferVo> transferVos = new ArrayList<>();
        List<SysUser> list = userService.selectUserList(user);
        for (SysUser sysUser : list) {
            TransferVo transfervo = new TransferVo();
            int clueNum = assignRecordMapper.countAssignCluesByUser(sysUser.getUserId());
            int businessNum = assignRecordMapper.countAssignBusinessByUser(sysUser.getUserId());
            if (clueNum + businessNum > 0) {
                transfervo.setUserName(sysUser.getUserName());
                transfervo.setClueNum(clueNum);
                transfervo.setBusinessNum(businessNum);
                transfervo.setUserId(sysUser.getUserId());
                transfervo.setPhonenumber(sysUser.getPhonenumber());
                transfervo.setCreateTime(sysUser.getCreateTime());
                transferVos.add(transfervo);
            }
        }
        return transferVos;
    }
}
